package com.holyant.goods.dto;

import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.enums.EnableStatusEnum;
import com.ruoyi.common.core.exception.CustomException;
import io.swagger.annotations.ApiModel;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 分销商品dto
 * 
 * @author z
 * @date 2022-07-15
 */
@Data
@ApiModel("分销商品")
public class GdsDistributionGoodsImportDto {

    private static final long serialVersionUID = 1L;
    @Excel(name = "店铺编码")
    private String shopCode;
    @Excel(name = "店铺名称")
    private String shopName;
    @Excel(name = "商家SKU")
    @NotEmpty(message = "商家SKU不能为空")
    private String sellerSku;
    @Excel(name = "平台SKU")
    @NotEmpty(message = "平台SKU不能为空")
    private String platformSku;
    @Excel(name = "业务类型", combo = {"京东供销", "京东一盘货"})
    @NotEmpty(message = "业务类型不能为空")
    private String busiType;
    @Excel(name = "商品名称")
    @NotEmpty(message = "商品名称不能为空")
    private String goodsName;
    @Excel(name = "品牌")
    @NotEmpty(message = "品牌不能为空")
    private String brandName;
    @Excel(name = "一级品类")
    @NotEmpty(message = "一级品类不能为空")
    private String categoryFirst;
    @Excel(name = "二级品类")
    @NotEmpty(message = "二级品类不能为空")
    private String categorySecond;
    @Excel(name = "三级品类")
    @NotEmpty(message = "三级品类不能为空")
    private String categoryThird;
    @Excel(name = "采购价")
    @NotNull(message = "采购价不能为空")
    private BigDecimal purPrice;
    @Excel(name = "生效状态", combo = {"生效", "失效"})
    @NotEmpty(message = "生效状态不能为空")
    @Pattern(regexp = "(生效|失效)", message = "生效状态只能为生效或失效")
    private String state;

    public String getState() {
        if (Objects.equals(state, "生效")) {
            return EnableStatusEnum.OK.getCode();
        } else if (Objects.equals(state, "失效")) {
            return EnableStatusEnum.DISABLE.getCode();
        } else {
            throw new CustomException("未知的生效状态: " + state);
        }
    }
}
